********************************************************
*Table A10: Robots and college enrollment: Placebo test*
********************************************************

*Education
use "$final_data_outcomes/czone_Students.dta", clear
merge 1:1 czone year using "$final_data_outcomes/IPEDS_EnrollmentCZ.dta", assert(1 3) nogenerate

*Automation
merge 1:1 czone year using "$final_data_automation/czones_ExposureAutomation.dta", assert(1 3) nogenerate

*Imports
merge 1:1 czone year using "$final_data_imports/czone_ExposureChina", assert(1 3) nogenerate

*Covariates
merge m:1 czone using "$final_data_covariates/czone1990_Covariates.dta", assert(3) nogenerate //beginning of period
merge m:1 czone using "$final_data_covariates/czone1970_Covariates.dta", assert(3) nogenerate //beginning of period
merge m:1 czone using "$final_data_covariates/IPEDS_institutionControlsCZ.dta", keep(1 3) nogenerate

xtset czone year

*Keep only periods of interest
keep if year<=2000

foreach var in public communityCollege uniTop20 uniTop30Dummy uniTop30 largest150 forProfit nonProfit numberOfUni private {
replace `var' = 0 if mi(`var')
}

egen medianAnyAid = median(anyAid), by(statefip)
	replace anyAid = medianAnyAid if mi(anyAid)
	
****** Gen initial shares
gen share_sc_1990 = ipums_pop_sc_1990 / ipums_pop_1990 * 100
gen share_sc_2000 = ipums_pop_sc_2000 / ipums_pop_2000 * 100
gen share_sc = share_sc_1990 if year == 1990
	replace share_sc = share_sc_2000 if year == 2000
******	

* reduced form
eststo clear
eststo: reghdfe d_sc_70_80_90 expof_euro7_qo d_exp_iv_stacked $occupations_1970 $demographics_1970 $industry_shares_1970 [w=ipums_pop_1970], absorb(division##year statefip) cluster(statefip)

eststo: reghdfe share_sc_1990 expof_euro7_qo d_exp_iv_stacked d_sc_70_90 $occupations_1990 $demographics_1990 $industry_shares_1990 $institutions_1990 [w=ipums_pop_1990] if year == 1990, absorb(statefip) cluster(statefip)

eststo: reghdfe share_sc_2000 expof_euro7_qo d_exp_iv_stacked d_sc_70_90 $occupations_1990 $demographics_1990 $industry_shares_1990 $institutions_1990 [w=ipums_pop_2000] if year == 2000, absorb(statefip) cluster(statefip)


estout using "$tables_appendix/Table A9.tex", style(tex) ///
varlabels(expof_euro7_qo "EU7 robot exposure") ///
cells(b(fmt(%9.3f) star) se(par)) nolabel replace mlabels(none) collabels(none) starlevels(\$^{*}\$ .1 \$^{**}\$ .05 \$^{***}\$ .01) /// 
keep(expof_euro7_qo) ///
order(expof_euro7_qo)


